#include <bits/stdc++.h>
#include <string>
using namespace std;

int arr[101][1001];  // arr[i][0] 代表编号为i的人被@了多少次
                     // arr[i][j] 代表编号为j的人被编号为i的人@过
int main()
{
    int n, m, a, b;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a >> m;
        for (int j = 0; j < m; j++)
        {
            cin >> b;
            arr[b][++arr[b][0]] = a;
        }
    }
    int max = -1, index = 0;
    for (int i = 1; i <= 100; i++)
    {
        if (arr[i][0] > max)
        {
            max = arr[i][0];
            index = i;
        }
    }
    cout << index << endl;
    sort(arr[index]+1,arr[index]+arr[index][0]+1);
    for (int i = 1; i <= arr[index][0]; i++)
    {
        cout << arr[index][i] << " ";
    }
    return 0;
}